package com.jianzhangg.springboot2.controller;

import com.jianzhangg.springboot2.bean.CommonResponse;
import com.jianzhangg.springboot2.bean.UserDO;
import com.jianzhangg.springboot2.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: jian.zhangg
 * @date: 2018/12/11 10:47
 * @version: V1.0
 * @Description: TODO
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService IUserService;

    @RequestMapping(method = RequestMethod.POST)
    public CommonResponse addUser(UserDO userDO) {
        Integer integer = IUserService.addUser(userDO);
        return new CommonResponse(true, integer);
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public CommonResponse findUser(@PathVariable("id") Long id) {
        UserDO userDO = IUserService.selectById(id);
        return new CommonResponse(true, userDO);
    }

}
